package com.shzu.jwc.ty.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shzu.jwc.ty.common.Msg;
import com.shzu.jwc.ty.bean.PeExaminationClass;
import com.shzu.jwc.ty.service.PeExaminationClassService;

@Controller
@RequestMapping("skilltestclass")
public class PeExaminationClasscontroller {

	@Autowired
	PeExaminationClassService peExaminationClassService;
	
	@RequestMapping("/skilltestclass.action")
	public String showskilltestclass(Model model)
	{
		model.addAttribute("data", peExaminationClassService.getclass());
		return "skilltestclass/skilltestclass";
	}
	
	@ResponseBody
	@RequestMapping("/insert.action")
	public Msg insert(PeExaminationClass examinationClass)
	{
		try {
			peExaminationClassService.insert(examinationClass);
			return Msg.success("插入成功");
		}catch(Exception ex)
		{
			return Msg.error("插入失败,"+ex.getMessage());
		}
	}
	
	@ResponseBody
	@RequestMapping("/delete.action")
	public Msg delete(@RequestParam("id")Integer peExaminationClassId)
	{
		try {
			peExaminationClassService.delete(peExaminationClassId);
			return Msg.success("操作成功");
		}catch(Exception ex)
		{
			return Msg.error("操作失败,"+ex.getMessage());
		}
	}
	
	@ResponseBody
	@RequestMapping("/update.action")
	public Msg update(@RequestParam("id")Integer id,@RequestParam("column")String column,@RequestParam("value")String value)
	{
		try {
			peExaminationClassService.update(id, column, value);
			return Msg.success("操作成功");
		}catch(Exception ex)
		{
			return Msg.error("操作失败,"+ex.getMessage());
		}
	}
}
